"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/5/13 8:35
@Description : 
元组
1. 如何定义元组  ()
2. 元组操作   元组中的元素是不可改变的  append   元组是列表的一种特殊形式


元组中存储元素的特点
1. 有序
2. 可重复
3. 不可改变
"""
#  tuple 空元组
tupl = ()
tupl = tuple()
print(id(tupl))
print(type(tupl))
# 创建非空元组
tupl = (0, 1, 2, 3, 4, 5, 6)
print(tupl)

#  元组中的元素是不可改变的
# tupl[0] = 10
print('----------------------元组操作--------------------------')
# 元组[index] 索引   支持正负索引
print(f'tupl[0] = {tupl[0]}')
print(f'tupl[-1] = {tupl[-1]}')
# tuple index out of range
# print(f'tupl[6] = {tupl[6]}')
print('----------------------元组遍历--------------------------')
# 元组是可迭代元素
for i in tupl:
    print(i)
print('===============')
# while
index = 0
while index < len(tupl):
    print(tupl[index])
    index += 1
print('----------------------元组切片--------------------------')
# 参照列表
result = tupl[:]
print(result)

print('----------------------元组通用操作--------------------------')
result = max(tupl)
print(f'max = {result}')

result = min(tupl)
print(f'min = {result}')
tupl2 = (10, 20, 30, 4, 5, 6)

result = tupl + tupl2
print(result)

# 重复元素
result = tupl * 2
print(result)

# 判定是否包含某个元素
result = 7 in tupl
print(result)

print('----------------------元组列表的转换--------------------------')
print(type(tupl))
# 元组  ->  列表
lst = list(tupl)
print(lst, type(lst))

tupl_lst = tuple(lst)
print(tupl_lst, type(tupl_lst))

print('----------------------元组元素的类型--------------------------')

tupl = ('1', 1, True)
print(tupl)
lst = ['1', 1, True]
print(lst)
